<template>
    <view class="custom-tab-bar">
      <view 
        v-for="(item, index) in tabList" 
        :key="index"
        class="tab-item"
        :class="{ active: current === index }"
        @tap="switchTab(item.pagePath, index)"
      >
        <text class="tab-text">{{ item.text }}</text>
        <view class="tab-circle" v-if="current === index"></view>
      </view>
    </view>
  </template>
  
  <script>
  export default {
    name: 'CustomTabBar',
    data() {
      return {
        current: 0,
        tabList: [
          { pagePath: '/pages/index/Home', text: '首页' },
          { pagePath: '/pages/guide/guide', text: '攻略' },
          { pagePath: '/pages/service/service', text: '服务' },
          { pagePath: '/pages/my/my', text: '我的' }
        ]
      }
    },
    methods: {
      switchTab(path, index) {
        if (this.current !== index) {
          this.current = index
          uni.switchTab({
            url: path,
            success: () => {
              // 添加触感反馈
              if (uni.vibrateShort) {
                uni.vibrateShort()
              }
            }
          })
        }
      }
    }
  }
  </script>
  
  <style scoped>
  .custom-tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: #ffffff;
    display: flex;
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
  }
  
  .tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.3s;
  }
  
  .tab-text {
    font-size: 12px;
    color: #7A7E83;
    transition: all 0.3s;
  }
  
  .tab-item.active .tab-text {
    color: #3cc51f;
    font-weight: bold;
    transform: translateY(-2px);
  }
  
  .tab-circle {
    position: absolute;
    top: -15px;
    width: 50px;
    height: 15px;
    background: radial-gradient(50px at center bottom, #f8f8f8 0%, transparent 100%);
    animation: slideIn 0.3s ease-out;
  }
  
  .tab-item::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(60, 197, 31, 0.1) 0%, transparent 60%);
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
  }
  
  .tab-item:active::after {
    transform: translate(-50%, -50%) scale(2);
    opacity: 1;
  }
  
  @keyframes slideIn {
    from {
      transform: translateY(100%);
      opacity: 0;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }
  </style>